package org.linlinjava.litemall.admin.web.order_manage;

import cn.com.ejiakanghu.core.vo.BaseResult;
import org.linlinjava.litemall.admin.service.order_manage.AgedmallServiceOrderAdminService;
import org.linlinjava.litemall.admin.vo.service_order.*;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.vo.order_manage.ServiceOrderPramVo;
import org.linlinjava.litemall.db.vo.service_order.ServiceMessage;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.constraints.NotNull;

/**
 * @author wj
 * @date 2021/8/13 10:20
 */
@RestController
@RequestMapping("/serice_order")
public class AgedmallServiceOrderController {


    @Resource
    private AgedmallServiceOrderAdminService agedmallServiceOrderAdminService;



    /**
     * 获取在线订单列表
     * @param serviceOrderPramVo
     * @return
     */
    @PostMapping("/onlineOrderList")
    public Object onlineOrderList(@RequestBody ServiceOrderPramVo serviceOrderPramVo){
        Object object = agedmallServiceOrderAdminService.onlineOrderList(serviceOrderPramVo);
        return object;
    }



    /**
     * 加载订单详情页
     */
   /* @GetMapping("/serviceOrderDetail")
    public Object serviceOrderDetail( @Validated ServiceOrderDetailVo serviceOrderDetailVo){
        return agedmallServiceOrderAdminService.serviceOrderDetail(serviceOrderDetailVo);
    }*/


    /**
     * 根据不同的服务订单状态加载订单详情页
     * @param orderId
     * @return
     */
   @GetMapping("/serviceOrderDetail")
   public Object serviceOrderDetail(String orderId){
       if(orderId == null || "".equals(orderId)){
           return ResponseUtil.fail("服务id为空!");
       }
       Object object = agedmallServiceOrderAdminService.serviceIdOrderDetailInfo(Long.parseLong(orderId));
        return object;
   }



    /**
     * 在线服务订单变更为已关闭状态
     * @param serviceOrderPramVo
     * @return
     */
    @PostMapping("/cancleServiceOrder")
    public Object cancleServiceOrder(@RequestBody ServiceOrderPramVo serviceOrderPramVo){
        return agedmallServiceOrderAdminService.cancleServiceOrder(serviceOrderPramVo.getId());
    }


    /**
     * 重新分配医生
     */
    @PostMapping("/distributeDoctor")
    public Object distributeDoctor(@RequestBody @Validated DistributeDoctorVo distributeDoctorVo){
        return agedmallServiceOrderAdminService.distributeDoctor(distributeDoctorVo);
    }


    /**
     *  点击完成按钮完成订单
     */
    @PostMapping("/finishOrder")
    public Object finishOrder(@RequestBody FinishOrderVo finishOrderVo){
        return agedmallServiceOrderAdminService.finishOrder(finishOrderVo);
    }


}
